<template>
	<view class="order">
		<view class="order-input">
			<!-- <uni-icons type="search" class="search-icon" size="20"></uni-icons> -->
			<image src="../../static/image/search.png" class="search-icon" mode=""></image>
			<input type="text" value="" placeholder="根据手机号、客户姓名、商品名称搜索订单" @focus="search" />
			<!-- 顶部导航 -->
			<view class="toptab">
				<view v-for="(item,index) in tab" :key="index" :class="curren==index ? 'active':''" class="item"
					@tap="changetab(index,item.filter)">
					{{item.name}}
					<view :class="curren==item.filter ? 'bottom-line':''"></view>
				</view>
			</view>
		</view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
			:up="upOption" height="0" style="min-height: 0;">
			<view class="item-content">

				<view class="item" v-for="(item,index) in  datalist" @click="orderDetail(item)" :key='index'>
					<view class="buyers">
						<view class="buyers-bigBox">
							<view class="buyers-box">
								<view class="buyers-left">
									<!-- 购买人姓名 -->
									<text class="buyers-name">{{item.name}}</text>
									<view class="courier" v-if="item.self ==10">
										快递订单
									</view>
									<view class="courier" v-if="item.self ==20">
										自提订单
									</view>
								</view>
								<!-- 订单状态 -->
								<view class="buyers-right">
									<text class="buyers-mobile">{{item.phone}}</text>
									<text class="goods-status">{{ item.orderStatusText }} </text>
								</view>
							</view>
							<view class="goods-detail">
								<view class="goods" v-for="(item1,index1) in item.productList" :key="index1">
									<!-- 新增加的模块提示 -->
									<view class="goods-newly">
										<view>
											<view class="goods-newly_icon" style="margin: 5px 0px;">
												{{ item.orderSourceText }}
											</view>
										</view>
										<view>
											<view v-if="item.status==50" class="goods-sta sta1">待自提</view>

											<view v-if="item.urlLink" @click.stop="copyLink(item.urlLink)">
												<!-- <uni-icons color="#077840" type="link" size="30"></uni-icons> -->
												<uni-tag size="mini" text="复制链接" type="primary" />
											</view>
										</view>
									</view>
									<view class="goods-top">
										<view class="goods-img">
											<image :src="item1.imagePath" mode=""></image>
										</view>
										<view class="goods-detail-text">
											<view class="goods">
												<span
													style='text-overflow: ellipsis;overflow: hidden;white-space: nowrap;'>
													{{item1.productName}}</span>
												<span>¥{{item1.productPrice}}</span>
											</view>
											<view class="goods-species">
												<span>{{item1.productAttr}}</span>
												<span>x{{item1.totalNum}}</span>

											</view>
											<view class="">
												<!-- 修改样式 -->
												<view class="time1" v-if="item.self==20 && item1.expectDeliveryTime ">
													预计提货时间:{{ formaterTime(item1.expectDeliveryTime) }}
												</view>
												<!-- 生产基地 -->
												<view class="time1">
													{{item1.productAddress}}
												</view>
											</view>
										</view>
									</view>
									<view class="packing">
										<view class="packing_right">
											<text>定金¥{{item1.depositPrice}}，</text>
											<text>尾款¥{{item1.finalPrice}}</text>
											<text>总价¥{{item1.totalPrice}}</text>
										</view>
									</view>
									<button size="mini" style="color: #fff;"
										v-if="item.orderButton && item.orderButton.confirmBtn"
										@click.stop="setProdcutTime(item,item1)">
										{{item1.pickupTime?'提货日期:'+item1.pickupTime:'选择提货日期'}}</button>

									<!-- 自提  自提订单20且订单状态为待确认20-->
									<!-- 	<view class="time1" @click.stop="time(item1,item)" v-if="item.self ===20">
										{{ (item1.expectDeliveryTime === '' || item1.expectDeliveryTime === null ) 
										? '请选择自提时间': formaterTime(item1.expectDeliveryTime)}}
									</view> -->

									<!-- 确认后显示快递的时间 -->
									<!-- <view class="time1" v-if="item.self ===10" @click.stop="time(item1,item)">
										{{ (item1.expectDeliveryTime === '' || item1.expectDeliveryTime === null )
											? '请选择发货时间': formaterTime(item1.expectDeliveryTime)}}
									</view> -->



									<!-- 
									手动注释
									<view v-if="item.status==4">
										<view >
											<view class=" sta" :class="[item1.residue_status=='该商品已全部自提'?'goods-sta2 sta3':(item1.residue_status=='该商品未自提'?'goods-sta sta1':'goods-sta1 sta2')]" >{{item1.residue_status}}</view>
										</view>
									</view>
									<view v-if="item.status==5">
										<view >
											<view class=" sta" :class="[item1.residue_status=='该商品已全部发货'?'goods-sta2 sta3':(item1.residue_status=='该商品未发货'?'goods-sta sta1':'goods-sta1 sta2')]" >{{item1.residue_status}}</view>
										</view>
									</view> -->
								</view>
								<view class="total-price">
									<span> 商品总计：</span>
									<span class='total'>
										定金¥{{ item.depositTotalPrice }}</span>
									<span class='total'>
										尾款¥{{item.finalPrice}}</span>
									<span class='total'>
										包装费¥{{item.packPrice}}</span>
									<span class='total'>
										实付金额¥{{item.orderPrice}}</span>
								</view>
							</view>
							<view class="order-number">
								<span>订单编号：</span>
								<span class='number'>{{item.orderNo}}</span>
							</view>
							<view class="order-number">
								<span>下单时间：</span>
								<span class='number'>{{item.createTime}}</span>
							</view>
							<view class="order-time">
								<span>用友单据编号：</span>
								<span class='time' v-if="item.yonyouCode">
									<span v-for="val in JSON.parse(item.yonyouCode)|| []">【{{val.code}}】</span>
								</span>
								<span class='time' v-else>单据未同步</span>
							</view>

							<view class="order-btn">
								<view class="confirm-btn btn btns"
									v-if="item.orderButton && item.orderButton.confirmBtn">
									<view @click.stop="confirmOrder(item)">
										确认订单
									</view>
								</view>
								<!-- v-if="item.status == 20 || item.status == 30" -->
								<!-- !refOptions.includes(item.refundStatus) -->
								<view class="" style="margin-left:10px;color: #fff;border: none;">
									<view class="refund-btn btn btns" @click.stop="refund(item)"
										v-if="item.orderButton && item.orderButton.refundApply">退款</view>
								</view>
								<!-- 待付尾款 -->
								<!-- <view class="confirm-btn btn btns" v-if="item.status === 30 && item.finalPayType === 40 
									 && !refOptions.includes(item.refundStatus)" @click.stop="backConfirm(item)">
									确认尾款</view> -->
								<!-- 快递发货 -->
								<view class="confirm-btn btn btns" v-if="item.orderButton && item.orderButton.deliveryBtn" @click.stop="gotoClick(item)">
									<uni-icons type="paperplane" style="color:#077840" size="22"></uni-icons>去发货
								</view>
							</view>
						</view>
					</view>
				</view>

			</view>
			<!-- 生成订单悬浮按钮 -->
			<uni-fab ref="fab" :pattern="pattern" horizontal="right" vertical='bottom' @fabClick="fabClick" />
		</mescroll-body>
		<uni-calendar ref="calendar" class="uni-calendar--hook" :selected="info.selected" :date="info.data"
			:insert="info.insert" :minDate='minDate' :lunar="info.lunar" :startDate="info.startDate" :range="info.range"
			@confirm="confirm" @close="close" />
		<w-picker :visible.sync="visible" mode="selector" value="1" default-type="label" :default-props="defaultProps"
			:options="selectorList" @confirm="onConfirm($event,'selector')" @cancel="onCancel" ref="selector">
		</w-picker>
		<!-- 确认尾款 -->
		<pop ref="pop" direction="center" height="fit-content" :is_mask="true" :width="80">
			<view class="mobile">
				<view class="mobile-text">
					上传截图<text style="font-size: 12px;color: orangered;">(只允许上传一张)</text>
				</view>
				<view v-if="backForm.fileId" style="width:140px;height:100px;margin: 5px auto;">
					<image style="width:140px;height:100px;" :src="imageUrls"></image>
				</view>
				<view class="mobile-input">
					<span @click="wkchooseImage">选择文件</span>
				</view>
				<view class="filetext" v-for="(file,index) in wkSelectFiles" :key="index">
					{{ file.name}}
				</view>
			</view>
			<!-- 
			有截图这个就不需要了
			<view class="mobile">
				<view class="mobile-text">
					线下支付渠道
				</view>
				<view class="mobile-input">
					<input type="text" v-model="backForm.paySource" />
				</view>
			</view>
			<view class="mobile">
				<view class="mobile-text">
					线下支付时间
				</view>
				<view class="mobile-input">
					<input type="text" readonly v-model="backForm.payTime" @focus="timeSelect('order-wk')" />
				</view>
			</view>
			<view class="mobile">
				<view class="mobile-text">
					线下支付流水号
				</view>
				<view class="mobile-input">
					<input type="text" v-model="backForm.tradeNo" />
				</view>
			</view> -->
			<view class="fott-btn">
				<view class="close" @click="cancleBack">关闭</view>
				<view class="confirm" @click="confirmBack">确认</view>
			</view>


		</pop>
		<!-- 确认订单 -->
		<pop ref="orderPop" direction="center" height="fit-content" :is_mask="true" :width="80">
			<!-- <view v-if="orderConfirmModel.payType === 40">
				<view class="mobile">
					<view class="mobile-text">
						上传截图<text style="font-size: 12px;color: orangered;">(只允许上传一张)</text>
					</view>
					<view v-show="orderConfirmModel.fileId" style="width:140px;height:100px;margin: 5px auto;">
						<image style="width:140px;height:100px;" :src="imageUrls"></image>
					</view>
					<view class="mobile-input">
						<span @click="chooseImage">选择文件</span>
					</view>
					<view class="filetext" v-for="(file,index) in selectFiles" :key="index">
						{{ file.name}}
					</view>
				</view>
			</view> -->
			<view class="mobile">
				<view class="mobile-text">
					请选择提货时间
				</view>
				<view class="mobile-input">
					<input type="text" readonly v-model="orderConfirmModel.pickupTime"
						@focus="timeSelect('order-fh')" />
				</view>
			</view>
			<view class="fott-btn">
				<view class="close" @click="confirmOrderCancle">关闭</view>
				<view class="confirm" @click="confirmOrderSave">确认</view>
			</view>
		</pop>
		<!-- 业务员退款填写 -->
		<pop ref="ywpop" direction="center" height="fit-content" :is_mask="true" :width="80">
			<view class="mobile">
				<view class="mobile-text">
					订单金额
				</view>
				<view class="mobile-input" style="margin-top: 5px;">
					<input type="text" disabled v-model="odForm.orderPrice" />
				</view>
			</view>
			<view class="mobile">
				<view class="mobile-text">
					退款金额
				</view>
				<view class="mobile-input" style="margin-top: 5px;">
					<input type="number" v-model="odForm.refundPrice" />
				</view>
			</view>
			<view class="mobile">
				<view class="mobile-text">
					退款方式
				</view>
				<view class="mobile-input" style="margin-top: 5px;">
					<uni-data-select filterable :clear='false' :localdata="TKList" v-model="odForm.moneyType">
					</uni-data-select>
				</view>
			</view>
			<view class="mobile">
				<view class="mobile-text">
					退还方式
				</view>
				<view class="mobile-input" style="margin-top: 5px;">
					<uni-data-select filterable :clear='false' :localdata="itemBackType == 20?THList2:THList" v-model="odForm.backType">
					</uni-data-select>
				</view>
			</view>
			<view class="mobile">
				<view class="mobile-text">
					退款原因
				</view>
				<view class="mobile-input" style="margin-top: 5px;">
					<input type="text" v-model="odForm.reason" />
				</view>
			</view>
			<view class="mobile">
				<view class="mobile-text">
					上传截图<text style="font-size: 12px;color: orangered;">(只允许上传一张)</text>
				</view>
				<view v-show="odForm.fileId" style="width:140px;height:100px;margin: 5px auto;">
					<image style="width:140px;height:100px;" :src="odForm.odFilePath"></image>
				</view>
				<view class="mobile-input">
					<span @click="tKchooseImage">选择文件</span>
				</view>
				<view class="filetext" v-for="(file,index) in selectFiles" :key="index">
					{{ file.name}}
				</view>
			</view>
			<view class="fott-btn">
				<view class="close" @click="odFormCancle">关闭</view>
				<view class="confirm" @click="odFormSave">确认</view>
			</view>

		</pop>
		<!-- 生产订单弹窗 -->
		<uni-popup ref="addPopup" type="bottom" background-color="#fff">
			<view class="popup-add-box">
				<uni-forms :rules="baseFormRules" ref="baseForm" label-width="200rpx" label-align="right"
					:modelValue="baseFormData">
					<uni-forms-item label="基地" name="produceAddress" required>
						<uni-data-select filterable :clear='false' v-model="baseFormData.produceAddress"
							:localdata="jdList" placeholder="请选择基地"></uni-data-select>
					</uni-forms-item>
					<uni-forms-item label="客户" name="userId" required>
						<uni-data-select filterable :clear='false' v-model="baseFormData.userId" :localdata="khList"
							placeholder="请选择客户"></uni-data-select>
					</uni-forms-item>
					<uni-forms-item label="请选择商品" required name="orderSelctProductName">
						<uni-easyinput :clearable='false' @focus="selGoods" v-model="baseFormData.orderSelctProductName"
							placeholder="请选择商品" />
					</uni-forms-item>
					<uni-forms-item label="优惠券" required>
						<view v-if="couponList.length > 0">
							<view @click="onTogglePopupCoupon" v-if="userCouponId">
								{{userCouponVo.name}}
							</view>
							<view v-else class="hascoupon" @click="onTogglePopupCoupon">
								{{ couponList.length }}张可用<text class="icon iconfont icon-jiantou"></text>
							</view>
						</view>
						<text v-else class="f24 gray9">无优惠券可用</text>
					</uni-forms-item>
					<uni-forms-item label="赠品信息" required>
						<text class="f24 gray9">商品名称：{{giftProduct.productName}}</text>
						<br />
						<text
							class="f24 gray9">商品规格：{{giftProduct.productAttr || (giftProduct.skuVo && giftProduct.skuVo.productAttr)}}</text>
						<br />
						<text class="f24 gray9">赠送数量：{{giftProduct.buyNum}}</text>
					</uni-forms-item>
					<uni-forms-item label="自提门店" required name="storeId">
						<uni-data-select filterable :clear='false' :localdata="userAddressList"
							v-model="baseFormData.storeId">
						</uni-data-select>
					</uni-forms-item>
					<uni-forms-item label="订单类型" required>
						<uni-data-checkbox v-model="baseFormData.orderType" :localdata="orderTypeList" />
					</uni-forms-item>
					<uni-forms-item label="新订单信息" v-if="JSON.stringify(CalcData) != '{}'">
						<text class="f24 gray9">优惠金额：￥{{CalcData.couponPrice || '0.00'}}</text>
						<br />
						<text class="f24 gray9">定金：￥{{CalcData.depositTotalPrice || '0.00'}}</text>
						<br />
						<text class="f24 gray9">尾款：￥{{CalcData.finalTotalPrice || '0.00'}}</text>
						<br />
						<text class="f24 gray9">包装费：￥{{CalcData.packagePrice || '0.00'}}</text>
						<br />
						<text class="f24 gray9">总金额：￥{{CalcData.totalPrice || '0.00'}}</text>
						<br />
						<text class="f24 gray9">优惠后总金额：￥{{CalcData.orderPayPrice || '0.00'}}</text>
					</uni-forms-item>
				</uni-forms>
				<view class="button-group">
					<button type="primary" size="mini" v-loading="submitLoading" @click="submit()">提交</button>
				</view>
			</view>
		</uni-popup>
		<!-- 选择商品弹窗 -->
		<uni-popup ref="popupGoods" type="bottom" background-color="#fff">
			<view class="popup-goods-box">
				<uni-section title="选择商品" type="line">
					<template v-slot:right>
						<!-- 选择 -->
						<view style="display: flex;">
							<uni-easyinput prefixIcon="search" v-model="searchGoodsVal" placeholder="请搜索商品名称"
								@input="searchGoods">
							</uni-easyinput>
							<uni-icons style="color: #077840;" type="checkmarkempty" class="icons-text" size="35"
								@click="addGoods"></uni-icons>
						</view>
					</template>
					<uni-card :isFull="true">
						<template v-slot>
							<view class="popup-content" v-for="val in filteredList" :key="val.id">
								<view class="popup-content-left">
									<checkbox-group @change="($event)=>checkboxChange($event,val)">
										<!-- val.stockNum == 0 || -->
										<checkbox :checked="val.check" />
									</checkbox-group>
									<view class="popup-box-custom-cover">
										<image class="popup-box-cover-image" mode="aspectFill" :src="val.imagePath">
										</image>
									</view>
									<view class="popup-content-text">
										<text>商品名称：{{val.productName}}</text>
										<text>品种：{{val.categoryParentName}}</text>
										<text>分类：{{val.categoryName}}</text>
										<text>规格：
											<!-- <template v-if="val.check">
												<span
													v-for="(item, index) in val.productAttr && ((val.productAttr.split(';')).splice(0, 2))"
													:key="index">
													{{ item.split(":")[0] + ':' }}
													<uni-tag :inverted="true" :text='item.split(" :")[1]'
														type="primary" />
												</span>
												<span style="display: flex; margin: 2px 0px;">颜 色：<uni-tag
														style="margin: 0 2px;" :key="_index"
														v-for="(cor,_index) in val.colorList"
														@click="tagClick(val, cor)" :inverted="false" :text="cor.color"
														:type="cor.check && 'primary'"></uni-tag></span>
											</template> -->
											<span>{{val.productAttr}},{{val.sku}}</span>

										</text>
										<text>库存：{{val.stockNum}}</text>
										<text>最小起订数量：{{val.minBuyCount}}</text>
										<text>定金比例：{{val.depositRatio}}</text>
										<text>优惠金额：￥{{val.couponPrice || '0.00'}}</text>
										<text>种植基地：{{val.produceAddressTxt}}</text>
									</view>
								</view>
								<view v-if="val.check" class="popup-content-right">
									<!-- <uni-number-box @change="selCoupon(val)" :min="val.minBuyCount" :max="val.stockNum"
										:value="val.buyNum" /> -->
									<uni-easyinput style="width: 150rpx;display: inline-block;" :clearable='false'
										v-model="val.buyNum" placeholder="请输入数量" @change="selCoupon(val)" />
								</view>
							</view>
						</template>
					</uni-card>
				</uni-section>
			</view>
		</uni-popup>
		<!--优惠券-->
		<Coupon :isCoupon="isCoupon" :couponList="couponList" @close="closeCouponFunc"></Coupon>
		<!-- 商品券弹窗选择 -->
		<selectProduct :isCoupon="isSelectProduct" :couponList="orderSelctProduct" @close="closeSelectProduct">
		</selectProduct>
	</view>

</template>
<script>
	import uniCalendar from '@/components/uni-calendar/uni-calendar.vue'
	import wPicker from "@/components/w-picker/w-picker.vue";
	import Coupon from "@/components/coupon.vue"
	import selectProduct from "@/components/select-product.vue"
	// 添加下拉刷新组件
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import pop from "@/components/ming-pop/ming-pop.vue"
	export default {
		mixins: [MescrollMixin],
		components: {
			uniCalendar,
			wPicker,
			pop,
			Coupon,
			selectProduct
		},
		data() {
			return {
				CalcData: {},
				searchGoodsVal: '',
				baseFormData: {
					orderType: 20,
					produceAddress: ''
				},
				jdList: [],
				submitLoading: false,
				userAddressList: [],
				orderSelctProduct: [], // 选择的商品
				giftProduct: {}, //赠品
				couponList: [], //优惠券
				userCouponId: '', //选择的优惠券
				isCoupon: false, //优惠券弹框
				isSelectProduct: false, //优惠券选择商品弹框
				userCouponVo: {},
				khList: [],
				spList: [],
				orderTypeList: [{
					text: '自提',
					value: 20
				}],
				TKList: [{
						text: '全部退款',
						value: 10
					},
					{
						text: '部分退款',
						value: 20
					},
					{
						text: '超额退款',
						value: 30
					},
				],
				THList: [{
						text: '原路退回',
						value: 10
					},
					{
						text: '余额退回',
						value: 20
					},
					{
						text: '银行转账',
						value: 30
					},
				],
				THList2: [
					{
						text: '余额退回',
						value: 20
					},
					{
						text: '银行转账',
						value: 30
					},
				],
				baseFormRules: {
					produceAddress: {
						rules: [{
								required: true,
								errorMessage: '请选择基地',
							},

						],
					},
					userId: {
						rules: [{
								required: true,
								errorMessage: '请选择客户',
							},

						],
					},
					orderSelctProductName: {
						rules: [{
								required: true,
								errorMessage: '请选择商品',
							},

						],
					},
					storeId: {
						rules: [{
								required: true,
								errorMessage: '请选择自提门店',
							},

						],
					}
				},
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#077840',
					buttonColor: '#077840',
					iconColor: '#fff'
				},
				imageUrls: '',
				backForm: {
					orderNumber: '',
					orderId: '',
					paySource: '',
					payTime: '',
					tradeNo: '',
					fileId: ''
				},
				tab: [{
						name: '全部',
						value: 0,
						filter: 'all'
					},
					{
						name: '待支付',
						value: 1,
						filter: 'payment'
					},
					{
						name: '待确认',
						value: 2,
						filter: 'notConfirm'
					},
					{
						name: '待付尾款',
						value: 3,
						filter: 'notFinalPayment'
					},
					{
						name: '待发货',
						value: 5,
						filter: 'delivery'
					},
					// fix 取消
					// {
					// 	name: '待自提',
					// 	value: 4,
					// 	filter: 'notPickup'
					// },

					{
						name: '待收货',
						value: 6,
						filter: 'received'
					},
					// fix 取消 
					// {
					// 	name: '待评价',
					// 	value: 7,
					// 	filter: 'notComment'
					// },
					// {
					// 	name: '已评价',
					// 	value: 8,
					// 	filter: 'commented'
					// },
					{
						name: '退款',
						value: 10,
						filter: 'refund'
					},
					{
						name: '已取消',
						value: 11,
						filter: 'cancel'
					}
				],
				refOptions: [20, 30],
				datalist: [],
				datalist1: [],
				curren: 0,
				goodsList: [],
				title: 'picker',
				selectorList: [],
				defaultProps: {
					"label": "title"
				},
				index: 0,
				calendar: false,
				isShow: false,
				visible: false,
				length: 0,
				date: '',
				id: 0,
				// 下拉刷新的组件 参数 可以 改变的
				downOption: {
					use: false,
					auto: false //是否在初始化后,自动执行downCallback; 默认true
				},
				upOption: {
					page: {
						num: 0,
						size: 10,
						time: null
					},
					auto: false, // 不自动加载
					noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty: {
						tip: '~ 空空如也 ~', // 提示
						icon: '/static/home/saber.png'
					},
					textNoMore: '—— 没有更多了 ——'
				},
				order_goods: [],
				info: {
					lunar: true,
					range: false,
					insert: false,
					selected: [],
					data: '',
					startDate: ''
				},
itemBackType:'',
				department: '',
				indexd: 0,
				indexc: 0,
				pitchItem: '', //选中的item
				isNoEX: true,
				pickItem: {},
				minDate: '',
				orderConfirmItem: {}, //确认订单选择数据
				orderConfirmModel: {
					orderId: '',
					pickupTime: '',
					paySource: '',
					payTime: '',
					tradeNo: '',
					payType: 0,
					timeType: '',
					fileId: ''

				},
				odForm: {
					orderId: 0,
					refundPrice: 0,
					orderPrice: 0,
					reason: '',
					fileId: '',
					odFilePath: ''
				},
				selectFiles: [],
				wkSelectFiles: [],
				setTimeProduct: null
			}
		},
		computed: {
			filteredList() {
				return this.spList.filter(item => {
					return item.productName.toLowerCase().includes(this.searchGoodsVal.toLowerCase());
				});
			}
		},
		onLoad(options) {
			uni.$on('updateOrderList', (data) => {

				this.orderListAll(this.tab[this.curren].filter)
			})
			uni.$on('detailStatus', () => {

				this.orderListAll('delivery')
			})
			if (options.status) {
				this.curren = Number(options.status) - 1
				this.orderListAll(options.status)

			} else {
				this.orderListAll('all')

			}
			// this.productionDepartment()
			// this.info.startDate='2021-01-15'
		},
		onShow() {
			this.orderListAll('all')
		},
		watch: {
			"baseFormData.produceAddress": {
				handler(v) {
					if (v) {
						this.productPageSkuFun();
					}
				},
				deep: true,
				immediate: true
			}
		},
		methods: {
			// 复制链接
			copyLink(link) {
				uni.setClipboardData({
					data: link,
					success: () => {
						uni.showToast({
							title: '链接已复制',
							duration: 2000
						});
					},
					fail: () => {
						uni.showToast({
							title: '复制失败',
							icon: 'none',
							duration: 2000
						});
					}
				});
			},
			// 生成订单提交
			submit(baseForm) {
				this.$refs.baseForm.validate().then(res => {
					this.submitLoading = true;
					// 最新参数
					let obj = {
						orderId: '',
						storeId: this.baseFormData.storeId,
						couponId: this.userCouponId,
						userId: this.baseFormData.userId,
						productParams: this.orderSelctProduct,
						giftProduct: this.giftProduct
					}
					this.api.shopUserCreate(obj).then(res => {
						const {
							code,
							msg,
							data
						} = res.data;
						console.log(res, 'res')
						this.submitLoading = false;
						if (code === 1) {
							this.tui.toast(msg)
							this.$refs.addPopup.close();
							// 刷新列表
							// this.orderListAll('all')
							// 到详情
							uni.navigateTo({
								url: '/pages/orderList/orderListDetail/orderListDetail?orderId=' +
									data
							})
						}
					})
				}).catch(err => {
					console.log('表单错误信息：', err);
				})
			},

			/*选择优惠卷*/
			onTogglePopupCoupon() {
				console.log(11111)
				let self = this;
				self.isCoupon = true;
				self.couponList = this.couponList;
			},
			/*关闭优惠券*/
			closeCouponFunc({
				item,
				couponType,
				e
			}) {
				console.log(item, couponType, e, 'werrew')
				if (!e) return;
				this.isCoupon = false;
				this.userCouponId = e;
				this.userCouponVo = item
				if (couponType == 40) {
					this.isSelectProduct = true;
				}

			},
			// 关闭选择优惠券商品
			closeSelectProduct({
				row,
				e
			}) {
				console.log(row, 'closeSelectProduct')
				this.giftProduct = row;
				this.isSelectProduct = false;
			},
			// 获取地址
			loadKhDetial(id) {

				this.api.storeIndex({
						pageIndex: 1,
						pageSize: 10000,
					})
					.then((result) => {
						console.log(result, 'result')
						const {
							code,
							data
						} = result.data;
						if (code == 1) {
							// data.userAddressList.map(val => {
							// 	val['text'] =
							// 		`${val.provinceName}/${val.cityName}/${val.regionName}/${val.detail}`
							// 	val['value'] = val.addressId
							// })
							this.userAddressList = [];
							if (data.records) {
								data.records.map(val => {
									val['value'] = val.storeId
									val['text'] = val.storeName
								})
							}
							this.userAddressList = data.records;
							console.log(this.userAddressList, 'this.userAddressList ')
						}
					})

			},
			tagClick(row, cor) {
				row.colorList.map(val => val.check = false)
				cor.check = !cor.check;
				if (cor.check) {
					row.productSkuId = cor.productSkuId
				}
			},
			// 获取规格
			skuList(_row, productId) {
				this.api.skuList({
					productId
				}).then(res => {
					const {
						code,
						data
					} = res.data;
					console.log(data, 'data-----')
					_row['colorList'] = data
					//默认选择第一个
					_row['colorList'][0]['check'] = true;
					_row['productSkuId'] = data[0]['productSkuId']
					this.spList = JSON.parse(JSON.stringify(this.spList))

				})
			},
			addGoods() {
				console.log(this.spList.filter(val => val.check), '选中的商品');
				this.orderSelctProduct = this.spList.filter(val => val.check);
				this.baseFormData.orderSelctProductName = (this.orderSelctProduct.map(val => val.productName)).join(',')
				this.baseFormData = JSON.parse(JSON.stringify(this.baseFormData))
				this.loadKhDetial(this.baseFormData.userId);
				this.$refs.popupGoods.close()
				//计算接口
				this.$nextTick(() => {
					this.orderModifyCalc();
				})
			},
			async checkboxChange(e, row) {
				// if (row.stockNum == 0 && !row.check) {
				// 	row.check = false
				// 	this.tui.toast('该商品库存不足!')
				// } else {
				row.check = !row.check;
				if (row.check && !row.buyNum) {
					row.buyNum = row.minBuyCount
				}
				// }

				// 选中之后选中规格
				// if (row.check) {
				// 	await this.skuList(row, row.productId);
				// }
			},
			// 获取商品
			productPageSkuFun() {
				// productLists 
				this.api.productPageSku({
					pageIndex: 1,
					pageSize: 999999,
					produceAddress: this.baseFormData.produceAddress
					// productType:1 // 普通商品 1
				}).then(res => {
					const {
						code,
						data
					} = res.data;
					console.log(data, 'data.records')
					if (data.records) {
						data.records.map(val => {
							val['value'] = val.userId
							val['text'] = val.realName
							val['check'] = false;
						})
						this.spList = data.records;
					}
					// if (data.productList && data.productList.records) {
					// 	data.productList.records.map(val => {
					// 		val['value'] = val.userId
					// 		val['text'] = val.realName
					// 		val['check'] = false;
					// 	})
					// 	this.spList = data.productList.records;
					// }
				})
			},
			// 获取客户
			userIndex() {
				this.api.userIndex({
					pageIndex: 1,
					pageSize: 999999,
					filterType: 'shopUser'
				}).then(res => {
					const {
						code,
						data
					} = res.data;
					console.log(data.records, 'data.records')
					if (data.records) {
						data.records.map(val => {
							val['value'] = val.userId
							val['text'] = val.realName
						})
						this.khList = data.records;
					}
				})
			},
			// 选择优惠券 编辑数量
			selCoupon(val) {
				this.$forceUpdate();
				this.spList = JSON.parse(JSON.stringify(this.spList))
				this.orderSelctProduct = this.spList.filter(sp => sp.check);
				this.$nextTick(() => {
					this.orderModifyCalc();
				})
			},
			// 计算接口
			orderModifyCalc() {

				let Obj = {
					orderId: '',
					couponId: this.userCouponId,
					userId: this.baseFormData.userId,
					productParams: this.orderSelctProduct,
					giftProduct: this.giftProduct
				}
				this.api.orderModifyCalc(Obj, true).then(res => {
					console.log(res, 'res')
					const {
						code,
						data,
						msg
					} = res.data;
					if (code == 1) {
						// 数据清空
						this.couponList = [];
						this.userCouponId = '';
						this.CalcData = data;
						this.couponList = data.couponList;
						data.userCouponVo && (this.userCouponId = data.userCouponVo.userCouponId)
						data.userCouponVo && (this.userCouponVo = data.userCouponVo)
						// 赠品
						if (data.giftProduct) {
							this.giftProduct = data.giftProduct;
						}
						// 商品信息
						if (data.productList) {
							this.orderSelctProduct.map(val => {
								data.productList.map(item => {
									if (val.productId == item.productId) {
										val.couponPrice = item.couponPrice
										val.depositPrice = item.depositPrice
										val.packagePrice = item.packagePrice
										val.totalPayPrice = item.totalPayPrice
										val.finalPrice = item.finalPrice
									}
								})
							})
						}
						// 强制刷新
						this.couponList = JSON.parse(JSON.stringify(this.couponList))
					} else {
						this.tui.toast(msg)
					}

				}).catch(e => {
					this.slCaleLoading = false;

				})
			},
			// 生成订单
			fabClick() {
				// this.$refs.addPopup.open()
				// 不能记录到历史
				uni.navigateTo({
					url: '/pages/orderList/add-order'
				})
			},
			//获取基地集合
			produceListFun() {
				this.api.produceList().then(res => {
					const {
						code,
						data
					} = res.data;
					if (code == 1) {
						data.map(val => {
							val['value'] = val.produceAddrId
							val['text'] = val.produceName
						})
						this.jdList = data;
					}
				})
			},
			selGoods() {
				this.$refs.popupGoods.open()
				// 回显选中的
				if (this.orderSelctProduct && this.orderSelctProduct.length) {
					this.spList.map(val => {
						this.orderSelctProduct.map(item => {
							if (item.productSkuId == val.productSkuId) {
								val.check = true
								val.buyNum = item.buyNum
							}
						})
					})
				}
			},
			formaterTime(time) {
				if (time) {
					const date = new Date(time)
					const year = date.getFullYear()
					const month = date.getMonth() + 1
					const day = date.getDate()
					return `${year}-${month >=10? month :'0'+month }-${day>=10? day :'0'+day}`
				}
				return ''
			},
			onTest() {
				window.open('#小程序://上云丰/vmIQrRgFtQks5Fv')
			},
			orderDetail(item) {

				uni.navigateTo({
					url: '/pages/orderList/orderListDetail/orderListDetail?orderId=' + item.orderId
				})
			},
			gotoClick(item) {
				// fix 取消之前的确认发货
				uni.navigateTo({
					url: '/pages/orderList/confirmDelivery/deliveryCourier/deliveryCourier?orderId=' + item.orderId
				})

			},
			price(item1, item) {
				console.log(item1);
				console.log(item);
				// item.order_goods.forEach(citem=>{
				// 	citem
				// })
				if (item1.group_type == 0) {
					if (item1.classifyname != '种苗') {
						if (item.all_amount < 100000) {
							if (item1.amount < 10000) {
								item1['price_money'] = item1.retail_price
							} else if (item1.amount < 100000) {
								item1['price_money'] = item1.price_one
							} else {
								item1['price_money'] = item1.price_two
							}
						} else {
							item1['price_money'] = item1.price_two
						}
					} else {
						if (item.all_amount < 100000) {
							if (item1.amount < 10000) {
								item1['price_money'] = item1.zhongmiao_price
							} else if (item1.amount < 100000) {
								item1['price_money'] = item1.zhongmiao_price_one
							} else {
								item1['price_money'] = item1.zhongmiao_price_two
							}
						} else {
							item1['price_money'] = item1.zhongmiao_price_two
						}
					}
				} else {
					item1['price_money'] = item1.retail_price
				}
				console.log(item1.price_money);
				return item1.price_money
			},
			product(item1, item) {
				if (item1.group_type == 0) {
					if (item.status == 2) {
						this.pitchItem = item1
						this.$refs.selector.show()
					}
				}
			},
			toNewOrderJson(order) {
				const json = {
					orderId: order.orderId,
					name: order.extractName, //提货人
					self: order.deliveryType, //10 快递 20 自提
					phone: order.extractPhone, //电话
					orderStatusText: order.orderStatusText,
					productList: order.productList, //订单商品 
					yonyouCode: order.yonyouCode,
					createTime: order.createTime,
					orderNo: order.orderNo,
					orderSourceText: order.orderSourceText,
					orderSource: order.orderSource,
					orderButton: order.orderButton,
					depositIsConfirm: order.depositIsConfirm,
					status: order.status,
					payPrice: order.payPrice, //定金 
					finalPrice: order.finalPrice, // 尾款
					packPrice: order.packPrice, //包装费
					orderPrice: order.orderPrice, //实付金额
					finalPayType: order.finalPayType,
					payType: order.payType,
					urlLink: order.urlLink,
					refundStatus: order.refundStatus
				}
				return json
			},
			time(item1, item) {

				if (item.status === 20) {
					this.pickItem = {
						order: item,
						product: item1
					}
					setTimeout(() => {
						this.$refs.calendar.open()
					}, 200)
				}


			},
			// 订单全部列表
			orderListAll(status, pageNumber = 1) {
				const $this = this
				this.status = status
				this.api.orderListAll({
					dataType: status,
					pageIndex: pageNumber,
					pageSize: 5
				}).then(res => {
					console.log(res)
					const data = res.data.data.orderList.records
					const code = res.data.code
					let arrys = $this.datalist
					if (pageNumber === 1)
						arrys = []
					if (code === 1 &&
						data && data.length > 0) {
						data.forEach(order => {
							const json = $this.toNewOrderJson(order)
							arrys.push(json)
						})
					}
					this.datalist = arrys
					console.log(this.datalist, 'datalist')
				}).catch(err => {

				})
			},
			// 获取传入下单时间跟天数
			pickTime(create, time) {
				let cn = Number(time)
				let cs = cn * 1000 * 60 * 60 * 24
				let ctime = new Date(cs + Number(create) * 1000)
				let y = ctime.getFullYear()
				let m = ctime.getMonth() + 1
				let d = ctime.getDate()
				let csv = y + '-' + m + '-' + d
				return csv
			},
			// 生产部门
			productionDepartment() {
				this.api.productionDepartment()
					.then(res => {
						console.log(res.data.data);
						this.selectorList = res.data.data
						console.log(this.selectorList);
					})
					.catch(err => {
						this.tui.toast(err)
					})
			},
			// 搜索
			search() {
				uni.navigateTo({
					url: '/pages/search/searchs'
				})
			},
			// 获取现在的时间戳
			nowTime() {
				let times = new Date()
				console.log(times);
				let year = times.getFullYear()
				let m = times.getMonth() + 1
				let d = times.getDate()
				let csv = year + '-' + m + '-' + d
				return csv
			},
			// confirm(e) {
			// 	console.log('confirm 返回:', e)
			// },
			close() {
				console.log('弹窗关闭');
			},
			// 分割字符串
			Unsplit(goods_spec) {
				var spec = goods_spec.split(',')
				return spec[0] + ';' + '; ' + spec[0]
			},
			setProdcutTime(item, item1) {
				this.setTimeProduct = item1
				// this.minDate = new Date(item1.expectDeliveryTime)
				this.$refs.calendar.open()
			},
			// 日历取消
			cancel() {
				// this.calendar = false
			},
			// 日历确认
			confirm(e) {
				console.log(e, '33333')
				// 单个选择
				if (this.setTimeProduct) {
					if(new Date(this.setTimeProduct.expectDeliveryTime).getTime() > new Date(e.fulldate).getTime()){
						this.tui.toast(`选择的日期不能小于预计发货日期`)
					}else{
						this.datalist.map(val => {
							if (val.productList) {
								val.productList.map(item => {
									if (item.productSkuId == this.setTimeProduct.productSkuId) {
										item['pickupTime'] = e.fulldate
									}
						
								})
							}
						})
					}
					
				} else {
					// 统一设置数据
					// 点确认的时候 判断预计和实际的时间
					// orderConfirmItem 最外层的item 不是里面 item1 
					let isNext = true;
					if (this.orderConfirmItem) {
						this.orderConfirmItem.productList.map(prod => {
							if (new Date(prod.expectDeliveryTime).getTime() > new Date(e.fulldate).getTime()) {
								isNext = false
							}
						})
					}
					if (!isNext) {
						this.tui.toast(`选择的日期不能小于预计发货日期`)
					} else {
						this.datalist.map(val => {
							if (val.productList) {
								val.productList.map(item => {
									item['pickupTime'] = e.fulldate
								})
							}
						})
						// 保存接口
						const postForm = {
							orderId: this.orderConfirmItem.orderId,
							products: []
						}
						postForm.products = this.getCheckProducts(postForm.orderId)
						this.postOrderConfirm(postForm)
					}
				}
				this.datalist = JSON.parse(JSON.stringify((this.datalist)))


			},
			// picker确认
			onConfirm(e) {
				this.pitchItem.department = e.obj.title
			},
			// picker取消
			onCancel() {
				console.log(34)
			},
			// 顶部导航
			changetab(index, status) {

				// this.datalist = this.datalist1
				this.curren = index
				if (index != 0) {
					this.datalist = this.datalist.filter(item => item.status == status)
				}
				if (status != 1) {
					// this.orderListAll(status)
					this.status = status
					this.mescroll.resetUpScroll()
				} else {
					this.status = 0
					this.mescroll.resetUpScroll()
				}


			},
			orderStatus(status) {
				this.api.orderListPart({
					status: status,
					uid: uni.getStorageSync('uid')
				}).then(res => {
					console.log(res.data)
					this.datalist = res.data.data.order
					// this.datalist1 = res.data.data.order


				}).catch(err => {

				})
			},
			aggree(item) {
				var that = this
				uni.showModal({
					title: '确定同意该退款？',
					content: '同意后无法取消',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							that.payRefund(item.id, item.out_trade_no)
							that.mescroll.resetUpScroll()
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			reject(item) {
				var that = this
				uni.showModal({
					title: '确定拒绝该退款？',
					content: '拒绝后无法取消',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							that.refuseRefund(0, item.id)

						} else if (res.cancel) {
							console.log('用户点击取消');

						}
					}
				});
			},
			// 退款
			refund(item) {
				console.log('退款', item)
				var that = this
				const $this = this
				$this.odForm.orderId = item.orderId
				$this.odForm.orderPrice = item.orderPrice
				$this.odForm.refundPrice = item.orderPrice
				$this.itemBackType = item.backType;
				$this.$refs['ywpop'].show()
			},
			odFormCancle() {
				const $this = this
				$this.odForm.orderId = ''
				$this.odForm.orderPrice = ''
				$this.odForm.refundPrice = ''
				$this.odForm.fileId = ''
				$this.odForm.odFilePath = ''
				$this.odForm.reason = ''
				$this.selectFiles = []
				$this.$refs['ywpop'].close()
			},
			odFormSave() {
				const $this = this
				const oldPrice = Number($this.odForm.orderPrice)
				const newPrice = Number($this.odForm.refundPrice)
				if (newPrice > oldPrice) {
					$this.tui.toast('退款金额已超过订单最大额')
					return
				}
				if (!$this.odForm.reason) {
					$this.tui.toast('清填写退款原因')
					return
				}
				if (!$this.odForm.fileId) {
					$this.tui.toast('请上传截图')
					return
				}
				$this.postRefunds(this.odForm)
			},
			postRefunds(item) {
				const $this = this
				$this.api.returnOrder({
						orderId: item.orderId,
						refundPrice: Number(item.refundPrice),
						fileId: item.fileId,
						tkType: item.tkType,
						backType: item.backType,
						reason: item.reason
					})
					.then(result => {
						const {
							code,
							msg
						} = result.data
						uni.hideLoading()
						if (code === 1) {
							$this.tui.toast('退款申请提交成功')
							$this.odFormCancle()
							$this.orderListAll($this.status, 1)
						} else {
							$this.tui.toast(msg)

						}
					})
			},
			// 确认退款
			payRefund(id, number) {
				this.api.payRefund({
						id,
						uid: uni.getStorageSync('uid')
					})
					.then(res => {
						// pay_type是0则是余额退款
						if (res.data.code == 200 && res.data.data.pay_type == 0) {
							this.api.refundCallbackOutTradeNo(number)
								.then(res => {
									this.orderListAll(0)
								})
						} else {
							this.orderListAll(0)
						}
					})
					.catch(err => {
						this.tui.toast(err)
					})
			},
			formDate(date) {
				const dt = new Date(date * 1000)
				const y = dt.getFullYear()
				const m = (dt.getMonth() + 1 + '').padStart(2, '0')
				const d = (dt.getDate() + '').padStart(2, '0')
				const hh = (dt.getHours() + '').padStart(2, '0')
				const mm = (dt.getMinutes() + '').padStart(2, '0')
				const ss = (dt.getSeconds() + '').padStart(2, '0')

				return `${y}-${m}-${d} `
			},
			// 取消退款
			refuseRefund(x, id) {
				this.api.refuseRefund({
						id,
						uid: uni.getStorageSync('uid')
					})
					.then(res => {
						if (res.data.code == 500) {
							this.tui.toast(res.data.data)
						} else {
							this.orderListAll(10)
						}
					})
					.catch(err => {
						this.tui.toast(err)
					})
			},
			// 退单接口
			singleCheck(type, order_id) {
				this.api.singleBack({
						type,
						order_id
					})
					.then(res => {
						console.log(res);
					})
					.catch(err => {})
			},
			// 补发
			reissue(item) {
				// uni.navigateTo({
				// 	url: './confirmDelivery/deliveryAllOrPart/deliveryAllOrPart?status='+item.status +'&id='+item.id
				// })
				// if(item.Eve=='确认发货'){

				// }else if(item.Eve=='确认自提'){

				// }else 
				if (item.Eve != '已全部发货' && item.Eve != '已全部自提') {
					if (item.status == 4) {
						uni.navigateTo({
							url: './confirmDelivery/deliveryAllOrPart/deliveryAllOrPart?status=' + item.status +
								'&id=' + item.id + '&order_id=' + item.id
						})
					}
					if (item.status == 5) {
						uni.navigateTo({
							url: './confirmDelivery/deliveryCourier/deliveryCourier?status=' + item.status +
								'&id=' + item.id + '&order_id=' + item.id
						})
					}
				}
			},
			//确认订单
			confirmOrder(item) {
				const $this = this
				$this.orderConfirmItem = item
				$this.orderConfirmModel = {
					orderId: item.orderId
				}
				const postForm = {
					orderId: item.orderId,
					products: []
				}
				const isTrue = this.checkProdcutTime(postForm.orderId)
				if (isTrue) {
					postForm.products = this.getCheckProducts(postForm.orderId)
					this.postOrderConfirm(postForm)
				}
			},
			// 如果没有设置时间就提示 否则就直接保存
			checkProdcutTime(orderId) {
				let list = this.datalist
				let isvlidate = true
				const newProducts = []
				outer: for (let i = 0; i < list.length; i++) {
					const row = list[i]
					if (row.orderId === orderId) {
						let pdlist = row.productList
						for (let j = 0; j < pdlist.length; j++) {
							const pRow = pdlist[j]
							newProducts.push({
								orderProductId: pRow.orderProductId,
								pickupTime: pRow.pickupTime
							})
							if (!pRow.pickupTime) {
								isvlidate = false;
								break outer
							}
						}
					}
				}
				if (!isvlidate) {
					this.tui.toast(`请选择提货时间,或者统一设置提货时间`)
					newProducts.length = 0
					this.$refs.calendar.open()
					return
				}
				return isvlidate
			},
			getCheckProducts(orderId) {
				let list = this.datalist
				const newProducts = []
				outer: for (let i = 0; i < list.length; i++) {
					const row = list[i]
					if (row.orderId === orderId) {
						let pdlist = row.productList
						for (let j = 0; j < pdlist.length; j++) {
							const pRow = pdlist[j]
							newProducts.push({
								orderProductId: pRow.orderProductId,
								pickupTime: pRow.pickupTime
							})
						}

					}

				}
				return newProducts
			},
			//确认订单取消
			confirmOrderCancle() {
				const $this = this
				$this.orderConfirmModel = {
					orderId: '',
					pickupTime: "",
					paySource: "",
					payTime: "",
					tradeNo: "",
					payType: 0,
					type: '',
					fileId: ''
				}
				$this.selectFiles = []
				$this.$refs['orderPop'].close()

			},
			tKchooseImage() {
				const $this = this
				uni.chooseImage({
					count: 1,
					sourceType: ['album', 'camera'],
					success: function(res) {
						$this.selectFiles = res.tempFiles
						console.log("fies", res.tempFiles)
						$this.uploadImages(res.tempFiles[0], 'ddtk')
					}
				})
			},
			chooseImage() {
				const $this = this
				uni.chooseImage({
					count: 1,
					sourceType: ['album', 'camera'],
					success: function(res) {

						$this.selectFiles = res.tempFiles
						console.log("fies", res.tempFiles)
						$this.uploadImages(res.tempFiles[0], 'qrdd')
					}
				})
			},
			wkchooseImage() {
				const $this = this
				uni.chooseImage({
					count: 1,
					sourceType: ['album', 'camera'],
					success: function(res) {
						$this.wkSelectFiles = res.tempFiles
						$this.uploadImages(res.tempFiles[0], 'qrwk')
					}
				})
			},
			uploadImages(file, type) {
				const $this = this
				$this.api.uploadImage(file)
					.then(result => {
						const {
							code,
							data,
							msg
						} = result
						if (code === 1) {
							if (type === 'qrdd') {
								$this.orderConfirmModel.fileId = data.fileId
								$this.imageUrls = data.filePath
							} else if (type === 'ddtk') {
								$this.odForm.fileId = data.fileId
								$this.odForm.odFilePath = data.filePath
							} else {
								$this.imageUrls = data.filePath
								$this.backForm.fileId = data.fileId
							}
						} else {
							$this.tui.toast(msg)
						}
						console.log('res', result)
					}).catch(error => {
						console.log('res', error)
					})
			},
			// 确认订单保存
			confirmOrderSave() {
				const $this = this
				const model = this.orderConfirmModel
				const postModel = {
					...model,
				}
				// if (model.payType === 40 && $this.selectFiles.length <= 0) {
				// 	this.tui.toast(`请上传截图`)
				// 	return
				// }
				this.postOrderConfirm(model)
			},
			postOrderConfirm(model) {
				const $this = this
				uni.showLoading({
					title: '确认中...'
				})
				$this.api.confirmOrder(model)
					.then(res => {
						const {
							code,
							msg
						} = res.data
						uni.hideLoading()
						if (code === 1) {
							this.tui.toast('订单确认成功')
							$this.orderListAll('all')
							$this.confirmOrderCancle()
						} else {
							this.tui.toast('订单确认失败')
							this.tui.toast(msg)
						}
					})
					.catch(err => {
						$this.tui.toast('订单异常')
						uni.hideLoading()
					})
			},
			timeSelect(type) {
				this.orderConfirmModel.timeType = type
				this.$refs.calendar.open()
			},
			backConfirm(item) {
				const $this = this
				$this.backForm.orderId = item.orderId
				$this.backForm.orderNumber = item.orderNo
				$this.$refs['pop'].show()
			},
			confirmBack() {
				const $this = this
				if ($this.wkSelectFiles.length <= 0) {
					$this.tui.toast('请上传付款截图')
					return
				}
				this.api.confirmBack($this.backForm)
					.then(result => {
						if (result.data.code === 1) {
							$this.orderListAll(status)
							$this.tui.toast(result.data.msg)
							$this.cancleBack()
						} else {
							$this.tui.toast(result.data.msg)

						}
					})
			},
			cancleBack() {
				const $this = this
				this.backForm.paySource = ''
				this.backForm.payTime = ''
				this.backForm.tradeNo = ''
				this.backForm.fileId = ''
				this.orderConfirmModel.timeType = ''
				this.wkSelectFiles = []
				$this.$refs['pop'].close()

			},
			// 关闭弹框
			close(e) {
				this.calendar = false

			},
			// picker
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
			},
			calendarChange(e) {
				console.log(e.fulldate)
				this.isShow = true

			},
			// 确认发货
			confirmDelivery(item) {

				if (item.status == 4) {
					uni.navigateTo({
						url: './confirmDelivery/deliveryAllOrPart/deliveryAllOrPart?status=' + item.status +
							'&id=' + item.id
					})
				}
				if (item.status == 5) {
					uni.navigateTo({
						url: './confirmDelivery/deliveryCourier/deliveryCourier?status=' + item.status + '&id=' +
							item.id
					})
				}
			},
			// 查看评价
			checkEvaluation(item) {
				console.log(12);
				uni.navigateTo({
					url: './historyEvaluation/historyEvaluation?order_id=' + item.id
				})
			},
			// 针对于退款 显示时间
			timeShow(time, spec, self, stock, amount, item1) {
				console.log(item1);
				// time后台配置的时间系数，spec规格,self判断是快递还是自提
				if (item1.group_type == 0) {
					let cn = spec.split(',')[0] //获取是什么类型
					if (cn == '种子') {
						// this.tiemCnv='预计一周内可发货/可自提'
						if (self == 0) {
							return '预计一周内可自提'
						} else {
							return '预计一周内可发货'
						}
					} else if (cn == '种苗') {
						if (self == 0) {
							return '预计' + (Number(time) + 7) + '天后可自提'
						} else {
							return '预计' + (Number(time) + 7) + '天后可发货'
						}
					} else if (cn == '种球') {
						if (self == 0) {
							return '待业务员确认订单后确认自提时间'
						} else {
							return '待业务员确认订单后确认发货时间'
						}
					}
				}
				if (item1.group_type != 0) {
					if (self == 0) {
						let c = this.formDate(item1.date)
						return '确定在' + c + '可自提'

					}
					if (self != 0) {
						let c = this.formDate(item1.date)
						return '确定在' + c + '可发货'
					}
				}
			},
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size;
				const $this = this
				this.api.orderListAll({
					dataType: this.status,
					pageIndex: pageNum,
					pageSize
				}).then(res => {
					const totalCount = res.data.data.orderList.total
					const orderLength = res.data.data.orderList.records.length
					console.log(res)
					let curPageLen = orderLength
					if (page.num == 1) this.datalist = [];
					const serverList = res.data.data.orderList.records
					const curPageData = []
					serverList.forEach(order => {
						const json = $this.toNewOrderJson(order)
						curPageData.push(json)
					})
					this.datalist = this.datalist.concat(curPageData);
					this.mescroll.endBySize(curPageLen, totalCount);

				}).catch(err => {
					this.tui.toast(err)
					this.mescroll.endSuccess()
				})
			},
			// 上拉加载

			// 是否是农资订单
			isFarmGoodOrder(orderInfo) {
				let goods = orderInfo.order_goods;
				if (!goods || goods.length === 0) {
					return false;
				}
				let arr = goods[0].spec.split(',');
				if (arr.length === 0) {
					return false;
				}
				return arr[0] === '农资';
			}
		},
	}
</script>
<style scoped>
	/deep/.uni-fab__circle {
		width: 30px;
		height: 30px;
	}

	/deep/.uni-forms-item {
		margin-bottom: 20rpx !important;
	}

	/deep/.uni-section-content {
		max-height: 50vh !important;
		overflow-y: auto !important;
	}

	/deep/.uni-select__selector-scroll {
		max-height: 230rpx !important;
	}

	/deep/.uni-section .uni-section-header__slot-right {
		width: 75% !important;
	}
</style>
<style lang="less" scoped>
	.hascoupon {
		padding: 0 18rpx;
		box-sizing: border-box;
		height: 38rpx;
		line-height: 38rpx;
		border-radius: 200rpx;
		color: #ffffff;
		background: linear-gradient(180deg, #fc4133, #ff7a04);
		font-size: 20rpx;
		width: fit-content;

		.icon.icon-jiantou {
			color: #ffffff;
			font-size: 20rpx;
			margin-left: 2rpx;
		}
	}

	.button-group {
		position: fixed;
		bottom: 105rpx;
		/* left: 40%; */
		width: 100%;
		background: #fff;
		padding-top: 10px;
	}

	.popup-content-text {
		uni-text {
			display: block;
			// width: 540rpx;
			white-space: pre-wrap;
			word-wrap: break-word;
		}
	}

	.popup-content {
		margin: 5px 0;
		border-bottom: 1px solid #077840;
	}

	.popup-add-box {
		min-height: 40vh;
		overflow-y: auto;
		margin-bottom: 180rpx;
	}

	.popup-goods-box {
		margin-bottom: 104rpx;
	}

	.fott-btn {
		display: flex;
		gap: 20px;

		.close {
			flex: 1;
			text-align: center;
			color: red;
			padding: 10px 5px;
		}

		.confirm {
			flex: 1;
			color: #077840;
			text-align: center;
			padding: 10px 5px;
		}

	}

	.mobile {
		padding: 20rpx 0;
		box-sizing: border-box;

		margin: 0 auto;
		border-bottom: 2px solid #EEEEEE;

		span {
			font-size: 14px;
			background: #4ba170;
			color: #fff;
			padding: 5px;
			display: block;
			text-align: center;
			margin: 5px;
		}

		.filetext {
			color: #4ba170;
			padding-left: 10px;
			font-size: 12px;
		}

		.mobile-text {
			margin-bottom: 0rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #333333;
		}

		.mobile-input input:placeholder {
			font-size: 28rpx;
			margin-top: 5px;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
		}
	}

	page {
		background-color: #F9F9F9;
	}

	.content-pop {
		// position: relative;
		position: absolute;
		top: 39%;
		left: 0;
		width: 100%;
	}

	.top {
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		background-color: #fff;
		position: absolute;
		top: -12%;
		left: 0;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		border-bottom: 1rpx solid #c8c7cc;
		font-size: 36rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;

		.confirm {
			color: #077840;
		}
	}

	.order-input {
		width: 100%;
		padding-top: 30rpx;
		padding-left: 25rpx;
		padding-right: 25rpx;
		box-sizing: border-box;
		background-color: #fff;
		position: fixed;
		top: 84rpx;
		left: 0;
		z-index: 123;


		input {
			height: 72rpx;
			width: 100%;
			background-color: #F6F6F6;
			border-radius: 36px;
			// padding-left: 224rpx;
			box-sizing: border-box;
			margin-bottom: 30rpx;
			text-align: center;

			&:placeholder {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #BEBEBE;
				line-height: 72rpx;
				text-align: center;
			}

		}

		.search-icon {
			width: 29rpx;
			height: 31rpx;
			color: #BEBEBE;
			position: absolute;
			top: 50rpx;
			left: 45rpx;

			.uni-icons {
				font-size: 30rpx;
			}
		}

		.toptab {
			// height: 102rpx;
			// margin-left: 30rpx;
			overflow-x: scroll;
			white-space: nowrap;

			.item {
				height: 60rpx;
				font-size: 30rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				// line-height: 60rpx;
				display: inline-block;
				margin-left: 30rpx;
				margin-right: 30rpx;

				// margin-top: 20rpx;
				&:first-child {
					margin-left: 10rpx;
				}
			}

			.active {
				font-weight: 500;
				color: #077840 !important;
			}

			.bottom-line {
				width: 60rpx;
				height: 4rpx;
				background: #077840;
				margin: 0 auto;
				margin-top: 16rpx;
			}
		}
	}

	.sta {
		height: 52rpx;
		background: #F3F8F6;
		border-radius: 8rpx;
		font-size: 22rpx;
		line-height: 52rpx;
		text-align: center;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #077840;
		// margin-bottom: 30rpx;
		padding: 0 10rpx;
		box-sizing: border-box;
	}

	.goods-sta {
		display: inline-block;
	}

	.goods-sta1 {
		// width: 252rpx;
		display: inline-block;

	}

	.goods-sta2 {
		display: inline-block;
		color: #999999;
		background-color: #EEEEEE;
	}

	.item-content {
		background-color: #F9F9F9;
		padding-top: 194rpx;
		box-sizing: border-box;

		.item {
			width: 690rpx;
			// height: 600rpx;
			margin: 0 auto;
			margin-top: 20rpx;
			background-color: #fff;
			padding-bottom: 30rpx;
			box-sizing: border-box;


			&:last-child {
				margin-bottom: 20rpx;
			}
		}

		.buyers {
			.buyers-bigBox {
				margin: 0 30rpx;

				.buyers-box {
					width: 100%;
					height: 99rpx;
					line-height: 99rpx;
					border-bottom: 2px solid #EEEEEE;
					display: flex;
					justify-content: space-between;

					.buyers-left {
						display: flex;
						justify-content: flex-start;

						.courier {
							width: 108rpx;
							height: 52rpx;
							border-radius: 8px;
							border: 2px solid #077840;
							margin-top: 20rpx;
							font-size: 22rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #077840;
							line-height: 52rpx;
							text-align: center;
						}

						.buyers-name {
							font-size: 26rpx;
							font-family: PingFangSC-Medium, PingFang SC;
							font-weight: 500;
							color: #333333;
							margin-right: 20rpx;
						}
					}

					.buyers-right {
						.buyers-mobile {
							font-size: 26rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #077840;
							margin-right: 20rpx;
						}

						.goods-status {
							font-size: 26rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #077840;
						}
					}

				}

				.goods-detail {
					// height: 350rpx;
					width: 100%;
					border-bottom: 2px solid #EEEEEE;
					margin-top: 28rpx;

					.goods-newly {
						margin-bottom: 28rpx;
						display: flex;
						justify-content: space-between;

						&_icon {
							width: 100rpx;
							height: 50rpx;
							font-size: 24rpx;
							font-family: PingFangSC-Medium, PingFang SC;
							font-weight: 500;
							color: #FFFFFF;
							line-height: 50rpx;
							background: linear-gradient(54deg, #FF7436 0%, #FF3333 100%);
							border-radius: 16rpx 0px 16rpx 0px;
							text-align: center;
						}

						/* 秒杀颜色 */
						&_color {
							background: linear-gradient(270deg, #FF904C 0%, #FF5F43 47%, #FF4B90 100%);
						}
					}

					.goods-top {
						display: flex;
						justify-content: flex-start;

						.goods-img {
							width: 180rpx;
							height: 180rpx;
							margin-right: 20rpx;

							image {
								width: 100%;
								height: 100%;
							}
						}

						.goods-detail-text {
							height: 180rpx;
							width: 430rpx;

							.goods {
								display: flex;
								justify-content: space-between;
								margin-bottom: 10rpx;
								font-size: 28rpx;
								font-family: PingFangSC-Regular, PingFang SC;
								font-weight: 400;
								color: #333333;
							}

							.goods-species {
								display: flex;
								justify-content: space-between;
								font-size: 24rpx;
								font-family: PingFangSC-Regular, PingFang SC;
								font-weight: 400;
								color: #999999;
							}
						}
					}

					.packing {
						display: flex;
						justify-content: space-between;
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						margin: 20rpx 0;

						.packing_right {
							flex: 1;
							// margin-left: 30rpx;
						}
					}

					.total-price {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						margin-bottom: 30rpx;

						.total {
							color: #333333;
						}
					}
				}

				.order-number {
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
					margin-top: 28rpx;

					.number {
						color: #333333;
					}
				}

				.order-time {
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;
					margin-top: 20rpx;
					margin-bottom: 30rpx;

					.time {
						color: #333333;
					}
				}

				.order-btn {
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					display: flex;
					justify-content: flex-end;

					.btn {
						width: 136rpx;
						height: 50rpx;
						line-height: 50rpx;
						text-align: center;
						background: #FFFFFF;
						border-radius: 8rpx;
					}

					.refund-btn {
						border: 2rpx solid #CECECE;
						// box-sizing: border-box;
						color: #666666;
					}

					.confirm-btn {
						border: 2rpx solid #077840;
						// box-sizing: border-box;
						color: #077840;
						margin-left: 10rpx;
					}

				}
			}
		}
	}

	.common {
		display: flex;
		justify-content: flex-end;
	}

	.sta-sty {
		view {
			margin-bottom: 0;
			margin: 4rpx 0 !important;
		}

		.sta1 {
			margin-right: 312rpx !important;
		}

		.sta2 {
			margin-right: 226rpx !important;
		}

		.sta3 {
			margin-right: 268rpx !important;
		}
	}

	/deep/uni-model .uni-model {
		width: 560rpx;
		height: 360rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
	}

	/deep/uni-modal .uni-modal__title {
		font-size: 36rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	/deep/uni-modal .uni-modal__bd {
		font-size: 30rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
	}

	.pop-up {
		width: 100%;
		height: 43%;
		background: rgba(0, 0, 0, .7);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9999;

		.calendar {
			width: 750rpx;
			height: 608rpx;
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 0px 0px;
			position: absolute;
			bottom: 0%;
			left: 0%;
			// padding: 0 10rpx;
			box-sizing: border-box;
		}
	}

	/deep/.w-picker-header uni-text:last-child {
		color: #077840 !important;
	}

	.time1 {
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FF6269;
		margin: 10rpx 0rpx;
	}

	.quanbu {
		width: 180rpx !important;
		background-color: #EEEEEE !important;
		color: #999999 !important;
		border: 0 !important;
	}

	.btns {
		border: 1px solid #097840;
		padding: 5px;
		border-radius: 5px;
		color: #097840;
	}
</style>